<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户信息管理</title> <#include "/WEB-INF/content/module-index.html">
<script type="text/javascript">
var areaTree=[
          	<#list map.areaTree as item>
          		{"id":"${item.id}","text":"${item.text}","children":[                                              
          			<#list item.children as ite>
          				{"id":"${ite.id}","text":"${ite.text}","children":[
          					<#list ite.children as it>
          						{"id":"${it.id}","text":"${it.text}","children":[
                       				<#list it.children as i>
                     						{"id":"${i.id}","text":"${i.text}"}<#if i_has_next>,</#if>
                     					</#list>						                                                 
          						]}<#if it_has_next>,</#if>
          					</#list>
          				]}<#if ite_has_next>,</#if>
          			</#list>
          		]}<#if item_has_next>,</#if>
          	</#list>
          ];
$(function(){
	$("#search").click(function(){
		var aid1=$("#aid1").combobox("getValue");
		var aid2=$("#aid2").combobox("getValue");
		var aid3=$("#aid3").combobox("getValue");
		var aid4=$("#aid4").combobox("getValue");
		$("#grid").datagrid("reload",{"aid1":aid1,"aid2":aid2,"aid3":aid3,"aid4":aid4});
	});
	$("#clear").click(function(){
		$("#aid1").combobox("setValue","");
		$("#aid2").combobox("setValue","");
		$("#aid3").combobox("setValue","");
		$("#aid4").combobox("setValue","");
	});
  	
  	$("#aid1").combobox({
  		valueField : 'id',
  		textField : 'text',
  		editable:false,
        panelHeight:'auto',
  		data:areaTree,
  		onChange:function(data){
			$("#s2").css("display","none");
			$("#s3").css("display","none");
			$("#s4").css("display","none");
			$("#aid2").combobox('setValue',"");
  			for(var i in areaTree){
  				if(areaTree[i].id==data){
  					var tree=areaTree[i].children;
  					if(tree.length>0){
  	  					$("#aid2").combobox('loadData',tree);
  	  					$("#s2").css("display","block");
  					}
  				}
  			}
  		}
  	});	
	$("#aid2").combobox({
	  		valueField : 'id',
	  		textField : 'text',
	  		editable:false,
	        panelHeight:'auto',
	        <#if map.secondData??>
			data:${map.secondData},
			</#if>
	        onChange:function(data){
				$("#s3").css("display","none");
 				$("#s4").css("display","none");
 				$("#aid3").combobox('setValue',"");
	        	var datas=$("#aid2").combobox("getData");
	  			for(var i in datas){
	  				if(datas[i].id==data){
	  					var tree=datas[i].children;
	  					if(tree.length>0){
	  	  					$("#aid3").combobox('loadData',tree);
	  	  					$("#s3").css("display","block");
	  					}
	  				}
	  			}
	        }
		});  	
	$("#aid3").combobox({
  		valueField : 'id',
  		textField : 'text',
  		editable:false,
        panelHeight:'auto',
        <#if map.thirdData??>
		data:${map.thirdData},
		</#if>        
        onChange:function(data){
        	$("#s4").css("display","none");
        	$("#aid4").combobox('setValue',"");
        	var datas=$("#aid3").combobox("getData");
  			for(var i in datas){
  				if(datas[i].id==data){
  					var tree=datas[i].children;
  					if(tree.length>0){
  	  					$("#aid4").combobox('loadData',tree);
  	  					$("#s4").css("display","block");
  					}
  				}
  			}
        }
	});  
	$("#aid4").combobox({
  		valueField : 'id',
  		textField : 'text',
  		editable:false,
        panelHeight:'auto',
        <#if map.fourthData??>
		data:${map.fourthData}
		</#if>        
	}); 	
	});
	
function statusFormatter(value,rowData,rowIndex){
	if(value==0){
		return "上货";
	}else
		if(value==1){
			return "已下货";
		}else
			return "未知";
}

function myEdit(){
	var status=getSelectItem().status;
	if(status==1){
		top.showMsg("改商品不能补货了");
	}else{
		edit();
	}
}
</script>
<style>
a.btn-border{
	border: 1px solid #ccc;
}
</style>
</head>
<body>
<body class="easyui-layout">
	<div region="center" style="padding: 5px; background:#eee;">
		<div id="toolbar">
<!-- 			<input name="aid1" id="aid1" placeholder="请选择区域"/>
			<input name="aid2" id="aid2" placeholder="请选择区域"/>
			<input name="aid3" id="aid3" placeholder="请选择区域"/>
			<input name="aid4" id="aid4" placeholder="请选择区域"/>
			<a id="clear" class="easyui-linkbutton" icon="icon-remove" style="border: 1px solid #ccc" plain="true">清空</a>
			<a id="search" class="easyui-linkbutton" icon="icon-search" style="border: 1px solid #ccc" plain="true">搜索</a>
			<br/> -->
			<@auth code="terminal:product:*:edit">
				<a id="edit" class="easyui-linkbutton" onclick="javascript:myEdit();" icon="icon-edit" style="border: 1px solid #ccc" plain="true">补货</a>
			</@auth>
			<@auth code="terminal:product:*:delete">
				<a id="delete" class="easyui-linkbutton" onclick="javascript:del();" icon="icon-cancel" style="border: 1px solid #ccc" plain="true">下货</a>
			</@auth>			
		</div>
		<table id="grid" class="easyui-datagrid" url="query" align="center" idField="ptid" rownumbers="true" striped="true" fitColumns="true" fit="true" pagination="true" singleSelect="true" toolbar="#toolbar">
			<thead>
				<tr>
					<th field="community" width="20">小区名称</th>
					<th field="serialno" width="20">终端名称</th>
					<th field="productname" width="20">商品名称</th>
					<th field="productamount" width="20">商品数量</th>
					<th field="status" width="20" formatter="statusFormatter">状态</th>
				</tr>
			</thead>
		</table>
	</div>
</body>
</body>

</html>